<template>
    <el-dialog title="思想汇报" :visible.sync="detailsVisible" width='1250px' append-to-body v-dialogDrag :close-on-click-modal="false" >
        <el-table :data="recoderfilesTrue"  border  :empty-text="showemptytext" >
            <el-table-column  width="120" label="标识"  align="center">
                <template slot-scope="scope">
                    <img class="default-image" :src="$store.state.images.wujiaoxing" style="width：45px;height:45px;">
                 </template>
            </el-table-column>
            <el-table-column type="index" label="序号"  align="center" width="60" :index="indexbf"></el-table-column>
            <el-table-column prop="truename" type="text" label="姓名" width="120" align="center" ></el-table-column>
            <el-table-column prop="date" type="text" label="思想汇报日期" width="160" align="center" :show-overflow-tooltip='true'  ></el-table-column>
            <el-table-column width="165" label="思想汇报文件" :show-overflow-tooltip='true' align="center">
                <template slot-scope="scope" >
                    <a target="_blank" :href="scope.row.content">点击查看</a>
                </template> 
            </el-table-column>
            <el-table-column  width="165" label="思想汇报文件" :show-overflow-tooltip='true' align="center">
                <template slot-scope="scope" >
                    <a target="_blank" :href="scope.row.truesrc">点击下载</a>
                </template> 
            </el-table-column>
            <el-table-column prop="store" width="165" label="志愿书存放" :show-overflow-tooltip='true' align="center"></el-table-column>
            <el-table-column align="right">
                <template slot="header" slot-scope="scope">
                    <el-button  size="mini"    @click="serchfile">查询</el-button>
                    <el-button  size="mini"    @click="addfile" v-show="showAdd==true">新增</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination @changed="showDataTrue" :recoder="recoderfiles"> </pagination>
        <addsxhb ref='addsxhb' v-on:editResult="serchfile"></addsxhb>
    </el-dialog>
</template>
<script>
    export default {
        data: () => ({
            detailsVisible:false,
            showAdd:false,//显示添加的按钮,  //只有党支部才可以显示添加
            truename:'',
            personid:'',
            //第二个表格
            recoderfiles:[], //获取到的文件
            recoderfilesTrue:[],//真正在表格里面显示的 由于分页等原因
            // 表格分页
            offset:0,

            default_emptytext:"请右侧添加思想汇报",
            showemptytext:'',

        }),
        mounted() {},
        watch: {
            "detailsVisible":{
                handler(){
                    if(this.detailsVisible==true){
                        this.serchfile();
                    }
                },
                deep:true
            }
        },
        components: {
            addsxhb: function(resolve) {require(["./addsxhb.vue"], resolve);},
        },
        methods: {
            serchfile(){
                this.recoderfiles=[];
                let _this=this;
                let postdata={
                    type:"serchsxhb",
                    split:JSON.stringify({
                        personid:this.personid
                    })
                }
                this.$Common.AjaxPost(postdata,true)
                .then(function(e){
                    if(e.length==0){
                        _this.showemptytext='没有找到记录';
                        setTimeout(() => {
                            _this.showemptytext=_this.default_emptytext;
                        }, 1000);
                    }
                    else{
                        _this.recoderfiles=e;
                    }
                }).catch(function(reason) {
                    console.log('catch:', reason);
                });
            },
            showDataTrue(showrecoders,offset){
                this.recoderfilesTrue=showrecoders;
                this.offset=offset;
            },
            indexbf(index){return index+this.offset+1;},
            addfile(){
                this.$refs.addsxhb.$data.dialogVisible = true;
                this.$refs.addsxhb.$data.rowdata.truename = this.truename;
                this.$refs.addsxhb.$data.rowdata.personid =this.personid;
            },
        }
    }
</script>
<style>
</style>